﻿#define _CRT_SECURE_NO_WARNINGS 1

//写一个函数，判断一个字符串是否为另外一个字符串旋转之后的字符串。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int left_revolve(char a[], const char c[], int num)
{
	int i = 0;
	int j = 0;
	int k = 0;
	char* b = (char*)malloc((num + 1) * sizeof(char));
	*(b + num) = '\0';
	for (i = 0; i < num; i++)
	{
		for (j = i; j < num; j++)
			*(b + j - i) = *(a + j);
		for (j = 0; j < i; j++)
			*(b + num - i + j) = *(a + j);
		if (strcmp(c, b))
			return 1;
	}

	return 0;
}

int main()
{
	//初始化
	int k = 0;
	char str1[20] = "hello world";
	char str2[20] = "llo worldhe";
	int num = strlen(str1);

	//设置一个函数去左旋字符
	int c = left_revolve(str1, str2, num);
	printf("%d", c);
	return 0;
}